using WeatherSystem.API.Models;

namespace WeatherSystem.API.Services.MessageQueue
{
    /// <summary>
    /// 消息队列服务接口
    /// </summary>
    public interface IMessageQueueService
    {
        /// <summary>
        /// 发布天气数据采集任务
        /// </summary>
        Task PublishWeatherDataCollectionTask(WeatherDataCollectionTask task);
        
        /// <summary>
        /// 发布批量数据处理任务
        /// </summary>
        Task PublishBatchDataProcessingTask(BatchDataProcessingTask task);
        
        /// <summary>
        /// 发布数据导出任务
        /// </summary>
        Task PublishDataExportTask(DataExportTask task);
        
        /// <summary>
        /// 发布告警通知
        /// </summary>
        Task PublishAlertNotification(AlertNotificationMessage notification);
        
        /// <summary>
        /// 发布系统事件
        /// </summary>
        Task PublishSystemEvent(SystemEventMessage eventMessage);
    }

    /// <summary>
    /// 天气数据采集任务
    /// </summary>
    public class WeatherDataCollectionTask
    {
        public string TaskId { get; set; } = Guid.NewGuid().ToString();
        public string[] CityIds { get; set; } = Array.Empty<string>();
        public string Source { get; set; } = "MessageQueue";
        public Dictionary<string, object> Parameters { get; set; } = new();
        public DateTime ScheduledAt { get; set; } = DateTime.UtcNow;
        public string UserId { get; set; } = "";
        public int Priority { get; set; } = 1; // 1-5, 1为最高优先级
    }

    /// <summary>
    /// 批量数据处理任务
    /// </summary>
    public class BatchDataProcessingTask
    {
        public string TaskId { get; set; } = Guid.NewGuid().ToString();
        public string OperationType { get; set; } = ""; // create, update, delete
        public string[] TargetIds { get; set; } = Array.Empty<string>();
        public Dictionary<string, object> Parameters { get; set; } = new();
        public DateTime ScheduledAt { get; set; } = DateTime.UtcNow;
        public string UserId { get; set; } = "";
        public int BatchSize { get; set; } = 100;
    }

    /// <summary>
    /// 数据导出任务
    /// </summary>
    public class DataExportTask
    {
        public string TaskId { get; set; } = Guid.NewGuid().ToString();
        public string ExportType { get; set; } = ""; // excel, csv, json
        public string DataType { get; set; } = ""; // weather, statistics, cities
        public Dictionary<string, object> Filters { get; set; } = new();
        public string[] Columns { get; set; } = Array.Empty<string>();
        public DateTime ScheduledAt { get; set; } = DateTime.UtcNow;
        public string UserId { get; set; } = "";
        public string CallbackUrl { get; set; } = "";
    }

    /// <summary>
    /// 告警通知消息
    /// </summary>
    public class AlertNotificationMessage
    {
        public string AlertId { get; set; } = "";
        public string RuleId { get; set; } = "";
        public string AlertType { get; set; } = "";
        public string Title { get; set; } = "";
        public string Message { get; set; } = "";
        public string Severity { get; set; } = ""; // low, medium, high, critical
        public Dictionary<string, object> Data { get; set; } = new();
        public string[] Channels { get; set; } = Array.Empty<string>(); // email, sms, webhook
        public DateTime TriggeredAt { get; set; } = DateTime.UtcNow;
    }

    /// <summary>
    /// 系统事件消息
    /// </summary>
    public class SystemEventMessage
    {
        public string EventId { get; set; } = Guid.NewGuid().ToString();
        public string EventType { get; set; } = "";
        public string Source { get; set; } = "";
        public string Message { get; set; } = "";
        public Dictionary<string, object> Data { get; set; } = new();
        public DateTime OccurredAt { get; set; } = DateTime.UtcNow;
        public string UserId { get; set; } = "";
        public string TraceId { get; set; } = "";
    }
}